﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.MarketUI {
    import flash.display.*;
    import Classes.*;
    import Display.*;
    import flash.text.*;
    import L10n.*;

    public class ItemCategoryToolTip extends Sprite {

        private static const SUBTITLE_MAX_WIDTH:int = 200;

        private var m_background:DisplayObject;
        private var m_beak:DisplayObject;
        private var m_tfTitle:TextField;
        private var m_tfSubtitle:TextField;
        private var m_titleFormat:TextFormat;
        private var m_subtitleFormat:TextFormat;

        public function ItemCategoryToolTip(){
            this.mouseChildren = (this.mouseEnabled = false);
            this.m_background = (new EmbeddedArt.mkt_category_bubble() as DisplayObject);
            addChild(this.m_background);
            this.m_beak = (new EmbeddedArt.mkt_category_beak() as DisplayObject);
            addChild(this.m_beak);
            this.m_titleFormat = new TextFormat(EmbeddedArt.TITLE_FONT, 20, 4759807);
            this.m_subtitleFormat = new TextFormat(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 16, EmbeddedArt.blueTextColor);
            this.m_tfTitle = new TextField();
            this.m_tfTitle.embedFonts = true;
            this.m_tfTitle.autoSize = TextFieldAutoSize.LEFT;
            this.m_tfTitle.defaultTextFormat = this.m_titleFormat;
            this.m_tfTitle.antiAliasType = AntiAliasType.ADVANCED;
            this.m_tfTitle.gridFitType = GridFitType.SUBPIXEL;
            addChild(this.m_tfTitle);
            this.m_tfSubtitle = new TextField();
            this.m_tfSubtitle.embedFonts = true;
            this.m_tfSubtitle.autoSize = TextFieldAutoSize.LEFT;
            this.m_tfSubtitle.defaultTextFormat = this.m_subtitleFormat;
            this.m_tfSubtitle.antiAliasType = AntiAliasType.ADVANCED;
            this.m_tfSubtitle.gridFitType = GridFitType.SUBPIXEL;
            addChild(this.m_tfSubtitle);
        }
        public function changeInfo(_arg1:String):void{
            this.m_tfTitle.text = ZLoc.t("Dialogs", (_arg1 + "_menu"));
            this.m_tfSubtitle.text = ZLoc.t("Dialogs", ("CTT_" + _arg1));
            if (this.m_tfSubtitle.width >= SUBTITLE_MAX_WIDTH){
                this.m_tfSubtitle.multiline = true;
                this.m_tfSubtitle.wordWrap = true;
                this.m_tfSubtitle.width = SUBTITLE_MAX_WIDTH;
            } else {
                this.m_tfSubtitle.multiline = false;
                this.m_tfSubtitle.wordWrap = false;
            };
            TextFieldUtil.formatSmallCaps(this.m_tfTitle, new TextFormat(EmbeddedArt.TITLE_FONT, 20));
            this.draw();
        }
        public function changeTitle(_arg1:String):void{
            this.m_tfTitle.text = _arg1;
            TextFieldUtil.formatSmallCaps(this.m_tfTitle, new TextFormat(EmbeddedArt.TITLE_FONT, 20));
            this.draw();
        }
        public function changeSubtitle(_arg1:String):void{
            if (_arg1.length > 0){
                this.m_tfSubtitle.text = _arg1;
                addChild(this.m_tfSubtitle);
            } else {
                if (contains(this.m_tfSubtitle)){
                    removeChild(this.m_tfSubtitle);
                };
            };
            this.draw();
        }
        protected function draw():void{
            LocaleHelper.localSetting.DisplayObject_adjust(this.m_background, {
                width:(this.m_background.width + 10),
                height:(this.m_background.height + 5)
            });
            this.m_background.width = (this.m_tfTitle.width + 20);
            this.m_background.height = (this.m_tfTitle.height + 5);
            if (contains(this.m_tfSubtitle)){
                this.m_background.width = Math.max(this.m_background.width, (this.m_tfSubtitle.width + 20));
                this.m_background.height = (this.m_background.height + this.m_tfSubtitle.height);
            };
            this.m_beak.y = (this.m_background.height - 6);
            this.m_beak.x = ((this.m_background.width * 0.5) - (this.m_beak.width * 0.5));
            this.m_tfTitle.x = ((this.m_background.width * 0.5) - (this.m_tfTitle.width * 0.5));
            this.m_tfSubtitle.x = ((this.m_background.width * 0.5) - (this.m_tfSubtitle.width * 0.5));
            this.m_tfSubtitle.y = ((this.m_tfTitle.y + this.m_tfTitle.height) - 5);
            LocaleHelper.localSetting.TextField_adjust(this.m_tfTitle, {y:4});
            LocaleHelper.localSetting.TextField_adjust(this.m_tfSubtitle, {y:27});
        }

    }
}//package Display.MarketUI 
